package com.ruoyi.web.controller.review;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.review.domain.SysEstimate;
import com.ruoyi.review.service.ISysEstimateService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价Controller
 * 
 * @author YJF
 * @date 2023-05-08
 */
@RestController
@RequestMapping("/review/estimate")
public class SysEstimateController extends BaseController
{
    @Autowired
    private ISysEstimateService sysEstimateService;

    /**
     * 查询评价列表
     */
    @PreAuthorize("@ss.hasPermi('review:estimate:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysEstimate sysEstimate)
    {
        startPage();
        List<SysEstimate> list = sysEstimateService.selectSysEstimateList(sysEstimate);
        return getDataTable(list);
    }

    /**
     * 获取评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('review:estimate:query')")
    @GetMapping(value = "/{estimateId}")
    public AjaxResult getInfo(@PathVariable("estimateId") Long estimateId)
    {
        return AjaxResult.success(sysEstimateService.selectSysEstimateByEstimateId(estimateId));
    }

    /**
     * 新增评价
     */
    @PreAuthorize("@ss.hasPermi('review:estimate:add')")
    @Log(title = "评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysEstimate sysEstimate)
    {
        return toAjax(sysEstimateService.insertSysEstimate(sysEstimate));
    }

    /**
     * 修改评价
     */
    @PreAuthorize("@ss.hasPermi('review:estimate:edit')")
    @Log(title = "评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysEstimate sysEstimate)
    {
        return toAjax(sysEstimateService.updateSysEstimate(sysEstimate));
    }

    /**
     * 删除评价
     */
    @PreAuthorize("@ss.hasPermi('review:estimate:remove')")
    @Log(title = "评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{estimateIds}")
    public AjaxResult remove(@PathVariable Long[] estimateIds)
    {
        return toAjax(sysEstimateService.deleteSysEstimateByEstimateIds(estimateIds));
    }
}
